package com.bird.postProcessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Configuration;

/**
 * @data 2023/2/19 17:39
 * @author: bird
 * @description: 容器的后置处理器
 */
@Configuration
public class CustomizedBeanFactoryPostProcessor implements BeanFactoryPostProcessor {

    /**
     *验证：
     * 1：容器的后置处理器，可以修改容器里面BeanDefinition实例的属性。在实例化之前。
     * 2：在所有的BeanDefinition实例注册完成之后才执行的方法。
     */
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println("开始加载BeanFactoryPostProcessor:处理器");
        BeanDefinition teacher = beanFactory.getBeanDefinition("teacher");
        teacher.setScope("singleton");


    }
}
